<?php
	include 'ZionHeader.inc';
?>

<html>
<body>

<?php
$FName = $_POST['fName'];
$MInitial = $_POST['mInitial'];
$LName = $_POST['lName'];
$Address = $_POST['address'];
$City = $_POST['city'];
$State = $_POST['state'];
$Zip = $_POST['zip'];
$Country = $_POST['country'];
$Phone1 = $_POST['phone1'];
$Phone2 = $_POST['phone2'];
$Phone3 = $_POST['phone3'];
$EMail = $_POST['eMail'];
$UserName = $_POST['username'];
$Password = $_POST['password1'];
$RePass = $_POST['passwordReType'];

//---For Dealers Only---
$Descript = $_POST['Descript'];
$URL = $_POST['URL'];
//---End Dealers Only---

$PhoneNumber = $Phone1.$Phone2.$Phone3;

$FullAddress = explode(' ', $Address);
$StreetNum = $FullAddress[0];
$Road = $FullAddress[1];

include 'DatabaseConnect.inc';

$query = "UPDATE User SET Password='$Password', Email='$EMail', PhoneNumber='$PhoneNumber', State='$State', City='$City', Street_Num='$StreetNum', Road='$Road', Zip_Code='$Zip', Country='$Country' WHERE LoginID = '$UserName'";
mysql_query($query);


$accounttype = $_SESSION['AType'];

//If user is registered user, we also update their first name, middle initial, last name.
if ($accounttype == 'R')
{
	$query = "UPDATE RegisteredUser SET FName='$FName', MInitial='$MInitial', LName='$LName' WHERE LoginID='$UserName'"; 
}
//If user is a dealer, we also update their description, as well as URL
else if ($accounttype == 'D')
{
	$query = "UPDATE Dealer SET Description='$Descript', URL='$URL' WHERE LoginID='$UserName'";
}	

mysql_query($query);
	
mysql_close();


?>

<h1>Your existing account has Been Updated!</h1>
<br />
<br />
<a href="index.php">Return To Index</a>


</body>
</html>